package ucenter

import (
	"github.com/jinzhu/gorm"
)

type UCMember struct {
	UID       int    	`gorm:"primary_key" json:"uid"`
	Username  string 	`json:"username"`
	Password  string 	`json:"password"`
	Salt      string    `json:"salt"`
	Role   	  string	`json:"role"`
	Meta 	  string     `json:"meta"`
}

type Meta struct {
	City 	string
}

func (UCMember) TableName() string{
	return "uc_members"
}


func GetOneMember(maps interface{}) (error, *UCMember) {
	member := &UCMember{}
	err  := udb.Select("username, uid, password, salt, role, meta").Where(maps).First(&member).Error
	if err != nil && err != gorm.ErrRecordNotFound {
		return err, nil
	}
	return nil, member
}